package com.dong.es.entity.searchparam.index;

import co.elastic.clients.elasticsearch.core.SearchRequest;
import com.dong.es.entity.EsBaseDTO;
import com.dong.es.entity.searchparam.EsSearchParam;
import org.apache.commons.lang3.StringUtils;

/**
 * @description: ES索引 参数
 * @author: 陈瑞东
 * @create: 2022-06-23 10:18
 */
public class EsIndexParam extends EsSearchParam<SearchRequest.Builder> {

    private static final long serialVersionUID = 4842025294587422495L;

    // 索引
    private String index;

    public EsIndexParam(String index) {
        this.index = index;
    }

    @Override
    protected boolean valid(EsBaseDTO esBaseDTO) {
        return StringUtils.isNotBlank(index);
    }

    @Override
    protected void addMethod(EsBaseDTO esBaseDTO) {
        setMethod(esBaseDTO);
    }

    @Override
    protected void setMethod(EsBaseDTO esBaseDTO) {
        esBaseDTO.index(this);
    }

    @Override
    public void loadTo(SearchRequest.Builder target) {
        target.index(index);
    }

}
